package com.bw.user.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.user.entity.HouseConcernEntity;
import com.bw.user.service.HouseConcernService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 房屋关注表
 *
 * @author Hao_YunKai
 * @email 2745578447@qq.com
 * @date 2022-03-23 11:45:27
 */
@RestController
@RequestMapping("user/house-concern")
public class HouseConcernController {
    @Autowired
    private HouseConcernService houseConcernService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseConcernService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{concernId}")
    public R info(@PathVariable("concernId") Long concernId){
		HouseConcernEntity houseConcern = houseConcernService.getById(concernId);

        return R.ok().put("houseConcern", houseConcern);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HouseConcernEntity houseConcern){
		houseConcernService.save(houseConcern);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HouseConcernEntity houseConcern){
		houseConcernService.updateById(houseConcern);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] concernIds){
		houseConcernService.removeByIds(Arrays.asList(concernIds));

        return R.ok();
    }

}
